package com.chengweiyi.security.security;

import com.chengweiyi.servicebase.utils.MD5;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;


/**
 * @Author xiao hu die
 * @Date 2022/5/11 18:52
 * @Version 1.0
 */
@Component
public class DefaultPassWordEncoder implements PasswordEncoder {
    /**使用MD5进行加密*/
    @Override
    public String encode(CharSequence charSequence) {
        String encrypt = MD5.encrypt(charSequence.toString());
        return encrypt;
    }
    /**进行对密码比*/
    @Override
    public boolean matches(CharSequence charSequence, String s) {
        return s.equals(MD5.encrypt(charSequence.toString()));
    }
}
